package org.weather;

import android.app.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

/**
 * Clasa chemata prin intent pentru adaugarea unui oras la lista de 
 * orase.
 * @author andrei
 *
 */
public class AddCity extends Activity {
	Button ok;
	Button cancel;
	EditText text;
	
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.addcity);
		
		ok = (Button)findViewById(R.id.adderOk);
		cancel = (Button)findViewById(R.id.adderCancel);
		text = (EditText)findViewById(R.id.adderText);
	}

	/**
	 * Aici intoarcem orasul pentru a fi adaugat in lista.
	 * @param v
	 */
	public void okListener(View v){
		// cream obiectul de raspuns
		Intent answer = new Intent ();
		// setam parametrii
		answer.putExtra ("name", text.getText().toString());
		//am adaugat, anuntam parintele
		setResult (1, answer);
		// inchidem dialogul
		finish ();
	}
	
	public void cancelListener(View v){
		setResult(0);
		finish();
	}
}
